home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / sound / sndblst4.zip / SPEAKER.DOC < prev    next >
Text File  |  1993-12-11  |  2KB  |  50 lines

  1.  
  2. In Windows/DOS Developer's Journal  December 1991, Robert Bybee wrote an
  3. article entitled 'Writing For The PC Speaker'.  The program SPEAKER.EXE
  4. is a butchered version of his program.
  5.  
  6. -The physics:
  7.  
  8.     The PC can write individual levels to the speaker directly (a 1 or a 0).
  9. It is also true that the PC can write these bits much faster than the speaker
  10. can respond to them.  At these speeds, the speaker becomes an integrator.
  11.  
  12. -1-Bit DACs:
  13.  
  14.     The latest craze in CD Players is 1-Bit dacs.  What is it?  Well...a
  15. 1-bit DAC really is not a DAC at all.  The sample is dithered (I will use
  16. that term from here on out, even if it is wrong) with a bit pattern whose
  17. integral (assume NRZL square wave) matches the level of the sample.  This
  18. n-length bit pattern is sent one bit at a time into an integrator at a bit
  19. rate of n (pattern length) times the sample rate.  From the integrator to the
  20. pre-amp to the amp, etc...
  21.  
  22. For example a 3-bit sample would require 8 discrete levels, which would
  23. require a 7-bit dither pattern:
  24.  
  25. dither           input
  26. 1111111     <--  111
  27. 1110111     <--  110
  28. 1101101     <--  101
  29. 1010101     <--  100
  30. 0101010     <--  011
  31. 0010010     <--  010
  32. 0001000     <--  001
  33. 0000000     <--  000
  34.  
  35. -Good quality PC Speaker sound:
  36.  
  37. Why not use the PC Speaker as an integrator for a 1-bit DAC?  Turns out to give
  38. pretty good quality sound.  The example program does not attempt to find out
  39. how fast your particular machine is.  You must adjust the bit pattern length
  40. until it sounds right, or figure it out the machine speed yourself.  With my
  41. 486DX2-66 I was running so fast that the speaker was overwhelmed and the volume
  42. was very low.  Adding a few NOPs to the end of the ophigh[] and oplow[] strings
  43. should slow it down some.  This will give fewer bits per second which will give
  44. better volume, but worse quality.
  45.  
  46. -Disclaimer:
  47.  
  48. This is not something I am going to develop further.
  49.  
  50.